//
//  AIGirlModelDetailNavView.swift
//  AIGirl
//
//  Created by Rae on 2023/12/29.
//

import UIKit

class AIGirlModelDetailNavView: UIView {

    private lazy var backButton = c_make_ex(UIButton.self)
        .image("AIGirl_Discover_back").end()
    private lazy var titleLabel = c_make_ex(UILabel.self)
        .color(.white).font(18.font_semiBold).alignment(.center).end()
    private lazy var VIPButton = c_make_ex(UIButton.self)
        .image("AIGirl_Discover_Detail_VIP").end()
    private lazy var totalCount = 0
    
    var backClosure: (() -> Void)?
    
    var isVip: Bool = false {
        didSet{
            VIPButton.isHidden = !isVip
        }
    }
    var picTotal: Int = 0 {
        didSet{
            totalCount = picTotal
        }
    }
    var currentIndex: Int = 0 {
        didSet{
            titleLabel.text = "\(currentIndex)/\(totalCount)"
        }
    }
        
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        subviews{
            backButton
            titleLabel
            VIPButton
        }
        
        backButton.leading(15).top(5).size(30)
        titleLabel.top(11).width(100).height(25).centerHorizontally()
        titleLabel.CenterY == backButton.CenterY
        VIPButton.trailing(15).width(49).height(47).bottom(0)
//        VIPButton.CenterY == backButton.CenterY + 5
        
        backButton.addTarget(self, action: #selector(back_control), for: .touchUpInside)
    }
    
    @objc private func back_control(){
        backClosure?()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
